#include <stdio.h>
#include <stdlib.h>


#define CODE 999

#define F_PRINT_ERR(e)\
do\
{\
    if(e == NULL)\
    {\
        printf("open error\n");\
        exit(-1);\
    }\
}\
while (0)

int main1()
{
    FILE * pfSrc = fopen("main.c","r+");
    F_PRINT_ERR(pfSrc);

    FILE * pfDes = fopen("maincode.c","w+");
    F_PRINT_ERR(pfDes);

    int ch;
    while ((ch = fgetc(pfSrc)) != EOF) {
        ch += CODE;
        fputc(ch,pfDes);
    }
    fclose(pfSrc);
    fclose(pfDes);

    return 0;
}

int main2()
{
    FILE * pfSrc = fopen("maincode.c","r+");
    F_PRINT_ERR(pfSrc);

    FILE * pfDes = fopen("maindecode.c","w+");
    F_PRINT_ERR(pfDes);

    int ch;
    while ((ch = fgetc(pfSrc)) != EOF) {
        ch -= CODE;
        fputc(ch,pfDes);
    }
    fclose(pfSrc);
    fclose(pfDes);

    return 0;
}



